metaContent = "pDcfDN8f3jz1r7XPqFGsPL6q9rSYtQFpgNsbPWxFArYi81IxUjQqVJWLCSbyMjvmpPyvkJOGoZQizOfI8SGYRSg.ZWDc2MpBkbeiYeTC0T2n07RtcD7cCyQ_xeajMYzzU28381JavZM7FlN4Pz3whmOha766Uu_TEYu3H4pK.j6M9UQzVj.Y2G"
self = top = window = global;
window.setTimeout = function () {
}
window.setInterval = function () {
}
window.clearInterval = function () {
}
window.addEventListener = function () {
}
window.XMLHttpRequest = function () {
}

div = {
    getElementsByTagName() {
        return []
    }
}
script = {

    getAttribute(attr) {
        if (attr === "r") {
            return "m"
        }
    },
    parentElement: {
        removeChild: function () {
        }
    }
}

meta = {
    content: metaContent,
    getAttribute(attr) {
        if (attr === "r") {
            return "m"
        }
    },
    parentNode: {
        removeChild: function () {
        }
    }

}

document = {
    createElement: function (ele) {
        console.log("document createElement", ele)
        if (ele === "div") {
            return div
        }
    },
    appendChild: function () {
    },
    removeChild: function () {
    },
    getElementsByTagName(ele) {
        console.log("document getElementsByTagName", ele)
        if (ele === "script") {
            return [script, script]
        }
        if (ele === "meta") {
            return [meta, meta]
        }else{
            return []
        }


    },
     documentElement: {
        addEventListener: function() {}
    },
    getElementById: function(param) {
        console.log("document.getElementById param=", param)
        return {}
    },
}
location = {
    "ancestorOrigins": {},
    "href": "https://www.ouyeel.com/steel/search?pageIndex=0&pageSize=50",
    "origin": "https://www.ouyeel.com",
    "protocol": "https:",
    "host": "www.ouyeel.com",
    "hostname": "www.ouyeel.com",
    "port": "",
    "pathname": "/steel/search",
    "search": "?pageIndex=0&pageSize=50",
    "hash": ""
}
navigator = {
    appCodeName: "Mozilla",
    appName: "Netscape",
    appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
    userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
    webdriver: false
}

function setProxyArr(proxyObjArr) {
    for (let i = 0; i < proxyObjArr.length; i++) {
        const objName = proxyObjArr[i];
        const handler = {
            get(target, property, receiver) {
                console.log("方法:", "get", "对象:", objName, "属性:", property, "属性类型：", typeof property, "属性值：", target[property], "属性值类型：", typeof target[property]);

                return target[property];
            },
            set(target, property, value, receiver) {
                console.log("方法:", "set", "对象:", objName, "属性:", property, "属性类型：", typeof property, "属性值：", value, "属性值类型：", typeof target[property]);
                return Reflect.set(target, property, value, receiver);
            }
        };
        // 检查并初始化对象
        let targetObject = global[objName] || {};  // 在 Node.js 环境中使用 global
        global[objName] = new Proxy(targetObject, handler);  // 在 Node.js 中使用 global
    }
}

setProxyArr(["window", "document", "location", "div", "script", "_head", "meta"])
